package com.sailfish.template.domain.iam.impl;

import com.sailfish.template.api.dto.pm.ProjectDTO;
import com.sailfish.template.domain.iam.ISteamIam;
import com.sailfish.template.infra.common.constants.ProjectConstant;
import com.sailfish.template.infra.common.utils.ProjectUtils;
import com.sailfish.template.infra.feign.vo.IamProjectVO;
import com.sailfish.template.infra.repository.iam.SteamIamRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author XIAXINYU3
 * @date 2021/11/9
 */
@Slf4j
@Service
public class ISteamIamImpl implements ISteamIam {
    @Autowired
    SteamIamRepository steamIamRepository;

    @Override
    public IamProjectVO create(Long organizationId, ProjectDTO project) {
        IamProjectVO steamProject = IamProjectVO.builder()
                .name(project.getName())
                .code(ProjectUtils.generateCode())
                .category(ProjectConstant.CATEGORY).build();
        return steamIamRepository.createProject(organizationId, steamProject);
    }
}
